<?php

namespace App\V3\V3_1\Services;
use App\V3\V3_1\Models\QuotationNoModel;
class QuotationNoService
{

    static public function add($data){

        return QuotationNoModel::add($data);
    }

    static public function update($condition,$data){

        return QuotationNoModel::upd($condition,$data);
    }
    static public function delete($condition){
        return QuotationNoModel::del($condition);
    }
    static public function getQuotationNoInfo($condition){

        return QuotationNoModel::getQuotationNoInfo($condition);
    }

    static public function getList($condition,$dispatch_id_arr,$pageSize,$pageNo){

        return QuotationNoModel::getList($condition,$dispatch_id_arr,$pageSize,$pageNo);
    }

    //物料商品列表
    static public function getInfo($mainId,$condition,$quotationId)
    {
        return QuotationNoModel::select("*")
            ->from('quotation_no')
            ->where('main_id', $mainId)
            ->with('nextTagList', function($query) {
                $query->select(
                    'id',
                    'tag_name'
                    ) ->with('nextGoodsList', function($query){
                        $query->select("*")
                        ->where($condition);
                    });
            })
            ->where('id',$quotationId)
            ->orderBy('id', 'asc');

    }
}
